#include "relay.h"


Relay::Relay(int pin) {
  _pin = pin;
  pinMode(_pin, OUTPUT);
  digitalWrite(_pin, LOW);
  _isOn = false;
}

void Relay::on() {
  if(!_isOn) {
    digitalWrite(_pin, HIGH);
    _isOn = true;
  }
}

void Relay::off() {
  if(_isOn) {
    digitalWrite(_pin, LOW);
    _isOn = false;
  }
}

boolean Relay::isOn() {
  return _isOn;
}

String Relay::getStatus() {
  return "R=" + String(_isOn);
}


